package com.xajh.duoduo.utils;

import com.sun.awt.AWTUtilities;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class ClickPosition {
    public static void main(String[] args) throws Exception {
        JFrame f = new JFrame("窗口");
        JMenuBar jmb=new JMenuBar();//菜单栏
        f.setJMenuBar(jmb);
        GraphicsDevice screenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
        GraphicsConfiguration configuration = screenDevice.getConfigurations()[0];
        Rectangle bounds = configuration.getBounds();
        f.setBounds(bounds);//设置窗口的大小 位置
        f.addMouseListener(new MouseListTest());
        f.setUndecorated(true);
        AWTUtilities.setWindowOpacity(f,0.3f);
        f.setVisible(true);//让窗口显示出来
    }

    static class MouseListTest implements MouseListener
    {
        @Override
        public void mouseClicked(MouseEvent e) {
            System.out.println("点击事件");
            System.out.println("x: "+e.getX());
            System.out.println("y: "+e.getY());
//            System.out.println(e.getClickCount());//和鼠标抬起差不多
        }
        @Override
        public void mousePressed(MouseEvent e) {
//            System.out.println("鼠标按下");
        }
        @Override
        public void mouseReleased(MouseEvent e) {
//            System.out.println("鼠标抬起");
        }
        @Override
        public void mouseEntered(MouseEvent e) {
//            System.out.println("鼠标进来了");
        }
        @Override
        public void mouseExited(MouseEvent e) {
//            System.out.println("鼠标出去了");
        }

    }
}
